package com.ease.core.components {

   import flash.events.MouseEvent;

   import mx.controls.ButtonPhase;
   import mx.controls.Menu;
   import mx.controls.PopUpMenuButton;
   import mx.core.IUIComponent;
   import mx.core.mx_internal;

   use namespace mx_internal;

   public class IconArrowPopUpMenuButton extends PopUpMenuButton {

      public function IconArrowPopUpMenuButton() {
         super();
         this.styleName = "iconArrowPopUpMenuButton";
         this.label = null; //to set labelSet=true;
      }

      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
         super.updateDisplayList(unscaledWidth, unscaledHeight);

         if (phase == ButtonPhase.DOWN && currentIcon) {
            currentIcon.x += 1;
            currentIcon.y += 1;
         }
      }

      override mx_internal function overArrowButton(event:MouseEvent):Boolean {
         if (openAlways) {
            return true;
         }
         else {
            return super.overArrowButton(event);
         }
      }

      override mx_internal function getPopUp():IUIComponent {
         var popUpComponent:IUIComponent = super.getPopUp();
         if (popUpComponent is Menu) {
            Menu(popUpComponent).variableRowHeight = true;
         }
         return popUpComponent;
      }
   }
}